package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"group-card/common/constant"
	"group-card/common/request"
	"group-card/model/entity"
	"group-card/rpc/card/cardclient"
	"group-card/rpc/card/internal/svc"
)

type BindingUnboundLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBindingUnboundLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindingUnboundLogic {
	return &BindingUnboundLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// region TODO: 取消绑定 Author:LiuYanLin Date:2023/07/03 周一 15:40
func (l *BindingUnboundLogic) BindingUnbound(in *cardclient.BindingUnboundRequest) (*cardclient.BindingUnboundResponse, error) {
	data := entity.CardBindingReq{
		Id:     in.Id,
		Status: constant.CardBindingStatus30,
		BaseReq: request.BaseReq{
			Columns: "status",
		},
	}

	var ctx context.Context
	err := l.svcCtx.BindingModel.Update(ctx, &data)

	if err != nil {
		return nil, err
	}

	return &cardclient.BindingUnboundResponse{}, nil
}

//endregion
